package com.hjm.admin.moule.api;

import com.allen.library.bean.BaseData;
import com.hjm.admin.moule.db.entity.UserBean;
import com.hjm.admin.moule.model.AppUpdateBean;
import com.hjm.admin.moule.model.BookBean;
import com.hjm.admin.moule.model.DeleteBookBean;

import java.util.List;

import io.reactivex.Observable;
import okhttp3.MultipartBody;
import retrofit2.http.Body;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.HTTP;
import retrofit2.http.Multipart;
import retrofit2.http.POST;
import retrofit2.http.PUT;
import retrofit2.http.Part;
import retrofit2.http.Query;

public interface UserService {
    @POST(ModelPath.USER + "register")
    @FormUrlEncoded
    Observable<BaseData<String>> register(@Field("name") String userName, @Field("password") String passWord);

    @GET(ModelPath.USER + "/login")
    Observable<BaseData<UserBean>> login(@Query("name") String username, @Query("password") String password);

    @PUT(ModelPath.USER + "/password")
    @FormUrlEncoded
    Observable<BaseData<String>> updatePassword(@Field("password") String password);

    @PUT(ModelPath.USER + "/userinfo")
    @FormUrlEncoded
    Observable<BaseData<String>> updateUserInfo(@Field("nickname") String nickname, @Field("brief") String brief);

    @GET(ModelPath.USER + "/userinfo")
    Observable<BaseData<UserBean>> getUserInfo();

    @Multipart
    @POST(ModelPath.USER + "/uploadavatar")
    Observable<BaseData<String>> avatar(@Part MultipartBody.Part part);

    @GET(ModelPath.USER + "/bookshelf")
    Observable<BaseData<List<BookBean>>> getBookShelf();

    @POST(ModelPath.USER + "bookshelf")
    @FormUrlEncoded
    Observable<BaseData<String>> addBookShelf(@Field("bookid") String bookid);

    @HTTP(method = "DELETE", path = ModelPath.USER + "/bookshelf", hasBody = true)
    Observable<BaseData<String>> deleteBookShelf(@Body DeleteBookBean deleteBookBean);


    @POST(ModelPath.API + "/feedback")
    @FormUrlEncoded
    Observable<BaseData<String>> userFeddBack(@Field("qq") String qq, @Field("feedback") String feedback);

    @GET(ModelPath.API + "/appupdate")
    Observable<BaseData<AppUpdateBean>> appUpdate();
}
